<?php
interface Travel {
    public function travelAlgorithm();
}

class AirPlanelStrategy implements Travel {

    public function travelAlgorithm()
    {
        echo "坐飞机\r\n";
    }
}

/**
 *乘坐火车
 */
class TrainStrategy implements Travel
{
    public function travelAlgorithm()
    {
        echo"坐火车\r\n";
    }
}

/**
 *
 *算法解决类，以提供客户选择使用何种解决方案：
 */
class PersonContext
{
    private $strategy = null;

    public function __construct(Travel $travel)
    {
        $this->strategy = $travel;
    }

    /**
     *旅行
     */
    public function travel()
    {
        return $this->strategy->travelAlgorithm();
    }

}
